﻿using System;
using System.Linq;
using LINQPad.Extensibility.DataContext;
using LINQPad.OpenAccess.Data;
using LINQPad.OpenAccess.Settings;
using Telerik.OpenAccess.Metadata;

namespace LINQPad.OpenAccess.Services
{
    /// <summary>
    /// DataContext - factory service.
    /// </summary>
    public interface IDataContextInitializationService
    {
        /// <summary>
        /// Gets the metadata for the specified context.
        /// </summary>
        /// <param name="contextType">Type of the context.</param>
        /// <param name="metadataSourceSettings">The metadata source settings.</param>
        /// <returns>
        /// The context metadata.
        /// </returns>
        MetadataContainer GetContextMetadata( Type contextType, MetadataSourceSettings metadataSourceSettings = null );
        /// <summary>
        /// Tries to get the constructor signature for the data context.
        /// </summary>
        /// <param name="connectionInfo">The connection info.</param>
        /// <param name="initializationSettings">The initialization settings.</param>
        /// <param name="parameters">The parameters.</param>
        /// <returns>
        ///   <c>true</c> on success; otherwise,<c>false</c>.
        /// </returns>
        bool TryGetContextConstructorSignature( IConnectionInfo connectionInfo, InitializationSettings initializationSettings, out ParameterDescriptor[] parameters );
        /// <summary>
        /// Gets the context initialization data for the specified context type.
        /// </summary>
        /// <param name="contextType">Type of the context.</param>
        /// <param name="connectionInfo">The connection info.</param>
        /// <param name="driverSettings">The driver settings.</param>
        /// <returns>
        /// The context intialization data.
        /// </returns>
        DataContextInitializationData GetContextInitializationData( Type contextType, IConnectionInfo connectionInfo, DriverSettings driverSettings );
    }
}
